const a = [
  {
    name: "张三",
    age: 18,
  },
  { name: "李四", age: 20 },
];

const b = [
  {
    name: "张三",
    age: 18,
  },
  {
    name: "王五",
    age: 18,
  },
  { name: "马六", age: 20 },
];

function findDifferences(arr1, arr2) {
  const diff = arr1.filter(
    (item1) =>
      !arr2.some(
        (item2) => item1.name === item2.name && item1.age === item2.age
      )
  );
  return diff;
}

const differences1 = findDifferences(a, b);
console.log(differences1);
const differences2 = findDifferences(b, a);
console.log(differences2);
